package utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;

public class SessionHelper {
	
	private static Logger logger = Logger.getLogger(SessionHelper.class);

	public static void setSessionAttribute(HttpServletRequest request,
			String attributeName, Object object) {
		
		HttpSession session = request.getSession(false);
		
		Object objectInSession = session.getAttribute(attributeName);
		if (objectInSession == null) {
			
			logger.info(String.format("Seteando atributo '%s' con object=%s",attributeName,object));
			session.setAttribute(attributeName, object);
		} else {
			logger.info(String.format("No hay que setear atributo '%s', ya tiene asociado object=%s",attributeName,objectInSession));
		}
		
	}

}
